package easy;

import org.junit.Test;

import java.util.Stack;

public class a456_模式132 {
    public boolean find132pattern(int[] nums) {
        int len = nums.length;
        Stack<Integer> Stack = new Stack<>();
        Stack.push(nums[0]);
        for (int i = 1; i < len; i++) {
            if (Stack.isEmpty() || nums[i] > nums[i - 1]) {
                Stack.push(nums[i]);
                if (i < (len - 1) && nums[i + 1] < nums[i] && nums[i + 1] > nums[i - 1]) {
                    return true;
                }
            }
        }
        return false;
    }

    @Test
    public void test() {
        int[] arr=new int[]{3,5,0,3,4};
        System.out.println(find132pattern(arr));
    }
}
